<%@ include file="IsStudent.jsp"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
    <head> 
        <%@ include file="../master/head.jsp" %>
        <%@ include file="IsStudent.jsp"%>
    </head>
    <body>
        <div id="container">
            <div id="wrapper">
                <div id="sidebar">
                    <div id="sb_top">
                        <%@ include file="../master/sbTop.jsp" %>
                    </div>
                    
                    <div class="sb_content">
                        
                        <!--##########-->
                        <!-- Start Menu -->
                        <%@ include file="../master/studentMenu.jsp" %>
                        
                        <!-- Profile -->
                        <%@ include file="../master/profile.jsp" %>
                        
                        <!-- links -->
                        <%@ include file="../master/links.jsp" %>
                        <div class="copyright">
                            <%@ include file="../master/copyright.jsp" %>
                        </div>
                        
                    </div> <!-- /sb_content -->
                </div> <!-- /sidebar -->
                
                
                <!-- Top -->
                <div id="header">
                    <%@ include file="../master/header.jsp" %>
                </div>
                
                
                <!-- Start main content -->
                <div id="content">
                    <div id="intro">
                        <div class="intro_t">
                            <h1><span>..</span>Welcome to<span>..</span></h1>
                            <h2 >student project managment system</h2>
                            
                        </div>
                    </div> <!-- /intro -->
                    
                    
                    <%@ page import="java.util.*,java.sql.*" %>
                    <%
                    String driver = "sun.jdbc.odbc.JdbcOdbcDriver";
                    try {
                    String un= (String) session.getAttribute("un");
                    String id=(String) session.getAttribute("id");
                    int proId = Integer.parseInt(request.getParameter("projId"));
                    
                    
                    
                    if (un == null)
                    {
                    out.println("<h1>Hi Guest </h1><br>" +
                    "You can rigester from <a href='../Student/studentRef.jsp'>here</a>");
                    }
                    else
                    {
                    out.println("<h1>Hi "+un+" <a href='logout.jps'>LOGOUT</a></h1>");
                    Class.forName(driver);
                    
                    Connection connection = DriverManager.getConnection("jdbc:odbc:SPMS","","");
                    
                    Statement statement = connection.createStatement();
                    
                    String query = "select * from project,professor WHERE project.ID="+ proId + " AND professor.ID = project.ProfessorID";
                    //String optionQuery = "select * from StudentProject WHERE ProjectID="+ proId + " AND StudentId ="+id;
                    // Execute query and save results.
                    ResultSet res = statement.executeQuery(query);
                    //ResultSet optionRes = statement.executeQuery(optionQuery);
                    %>
                    
                    <form action="updateProject.jsp" method="post">
                        <TABLE ID="tabM" ALIGN="CENTER" >
                            <%
                            if (res.next())
                            {
                            out.println("<TR><TD>Doctor Name</TD></TD> <TD><input name='profName' value="+res.getString(17)+" "+res.getString(18)+" disabled></TD></TR>");
                            out.println("<TR><TD>Project ID</TD></TD> <TD><input type='text' name='projId' value="+res.getString(1)+" readonly></TD></TR>");
                            out.println("<TR><TD>Title</TD></TD> <TD><input name='title' value="+res.getString(2)+" disabled></TD></TR>");
                            out.println("<TR><TD>Description</TD></TD> <TD><textarea name='desc' disabled>"+res.getString(3)+"</textarea></TD></TR>");
                            out.println("<TR><TD>Objective</TD></TD> <TD><textarea name='obj' disabled>"+res.getString(4)+"</textarea></TD></TR>");
                            out.println("<TR><TD>requirement</TD></TD> <TD><textarea name='req' disabled>"+res.getString(5)+"</textarea></TD></TR>");
                            out.println("<TR><TD>Tools</TD></TD> <TD><textarea name='tools' disabled>"+res.getString(6)+"</textarea></TD></TR>");
                            out.println("<TR><TD>Difficulty</TD></TD> <TD><textarea name='diff' disabled>"+res.getString(7)+"</textarea></TD></TR>");
                            out.println("<TR><TD>Type</TD></TD> <TD><textarea name='type' disabled>"+res.getString(8)+"</textarea></TD></TR>");
                            out.println("<TR><TD>Keyword</TD></TD> <TD><textarea name='keyword' disabled>"+res.getString(9)+"</textarea></TD></TR>");
                            out.println("<TR><TD>Result</TD></TD> <TD><textarea name='result' disabled>"+res.getString(10)+"</textarea></TD></TR>");
                            out.println("<TR><TD>Comment</TD></TD> <TD><textarea name='comment' disabled>"+res.getString(11)+"</textarea></TD></TR>");
                            }
                            if (res.getInt("studentId") == id)
                            {
                            }else
                            {
                            %>
                            <TR><TD><DIV ID="hide"><select name="setProj" title="Select Priority for Project">
                                            
                                            <option value=-1 >not selected
                                            <option value=1 >set this project as First Project Choice
                                            <option value=2 >set this project as Second Project Choice
                                            <option value=3 >set this project as Third Project Choice
                            </select></DIV></td></TR>
                            <TR><TD ><input type="submit" value = "return and Take my choice" /> </TD> <TD>
                            <% 
                            }
                            %>
                        </TABLE>
                    </form >
                    <%
                    }} catch(ClassNotFoundException cnfe) {
                    out.println("No such class: " + driver);
                    } catch(SQLException se) {
                    out.println("SQLException: " + se);
                    }
                    
                    %>
                    
                </div> <!-- /content -->
                
            </div> <!-- /wrapper -->
            <div class="clear">&nbsp;</div> <!-- Important! Fix the problem of height in Firefox -->
        </div> <!-- /Container -->
        
        
    </body>
</html>